﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExtAppBuilder.Ext.Configuration
{
    /// <summary>
    /// Configuration object for the Ext.Component
    /// </summary>
    public class ComponentConfig: ObservableConfig
    {        
        /// <summary>
        /// Whether the component can move the Dom node when rendering (defaults to true).
        /// </summary>
        public bool AllowDomMove { get; set; }

        /// <summary>
        /// This value is what tells the layout how an item should be anchored to the container.
        /// Note: this config is only used when this Component is rendered by a Container which 
        /// has been configured to use an AnchorLayout based layout manager.
        /// </summary>
        public string Anchor { get; set; }

        /// <summary>
        /// Specify the id of the element, a DOM element or an existing Element corresponding to a 
        /// DIV that is already present in the document that specifies some structural markup for 
        /// this component.
        /// </summary>
        public object ApplyTo { get; set; }

        /// <summary>
        /// A tag name or DomHelper spec used to create the Element which will encapsulate this Component.
        /// You do not normally need to specify this. For the base classes Ext.Component, Ext.BoxComponent, 
        /// and Ext.Container, this defaults to 'div'. The more complex Ext classes use a more complex DOM 
        /// structure created by their own onRender methods.
        /// This is intended to allow the developer to create application-specific utility Components 
        /// encapsulated by different DOM elements. 
        /// </summary>
        public object AutoEl { get; set; }

        /// <summary>
        /// True if the component should check for hidden classes (e.g. 'x-hidden' or 'x-hide-display') and 
        /// remove them on render (defaults to false).
        /// </summary>
        public bool AutoShow { get; set; }

        /// <summary>
        /// The CSS class used to to apply to the special clearing div rendered directly after each form field 
        /// wrapper to provide field clearing (defaults to 'x-form-clear-left')
        /// </summary>
        public string ClearCls { get; set; }

        /// <summary>
        /// An optional extra CSS class that will be added to this component's Element (defaults to ''). 
        /// This can be useful for adding customized styles to the component or any of its children using 
        /// standard CSS rules.
        /// </summary>
        public string Cls { get; set; }

        /// <summary>
        /// An optional extra CSS class that will be added to this component's container. This can be useful 
        /// for adding customized styles to the container or any of its children using standard CSS rules.
        /// </summary>
        public string CtCls { get; set; }

        /// <summary>
        /// Render this component disabled (default is false).
        /// </summary>
        public bool Disabled { get; set; }

        /// <summary>
        /// CSS class added to the component when it is disabled (defaults to 'x-item-disabled').
        /// </summary>
        public string DisabledClass { get; set; }

        /// <summary>
        /// The label text to display next to this Component (defaults to '').
        /// Note: this config is only used when this Component is rendered by a Container which has been 
        /// configured to use the FormLayout layout manager
        /// </summary>
        public string FieldLabel { get; set; }

        /// <summary>
        /// Render this component hidden (default is false). If true, the hide method will be called internally.
        /// </summary>
        public bool Hidden { get; set; }

        /// <summary>
        /// true to completely hide the label element (label and separator). Defaults to false. By default, 
        /// even if you do not specify a fieldLabel the space will still be reserved so that the field will 
        /// line up with other fields that do have labels. Setting this to true will cause the field to not 
        /// reserve that space.
        /// </summary>
        public bool HideLabel { get; set; }

        /// <summary>
        /// How this component should be hidden. Supported values are 'visibility' (css visibility), 
        /// 'offsets' (negative offset position) and 'display' (css display).
        /// Note: the default of 'display' is generally preferred since items are automatically laid out 
        /// when they are first shown (no sizing is done while hidden).
        /// </summary>
        public string HideMode { get; set; }

        /// <summary>
        /// True to hide and show the component's container when hide/show is called on the component, false 
        /// to hide and show the component itself (defaults to false). For example, this can be used as a 
        /// shortcut for a hide button on a window by setting hide:true on the button when adding it to its 
        /// parent container.
        /// </summary>
        public bool HideParent { get; set; }

        /// <summary>
        /// The unique id of this component (defaults to an auto-assigned id). You should assign an id if 
        /// you need to be able to access the component later and you do not have an object reference 
        /// available (e.g., using Ext.getCmp).
        /// Note that this id will also be used as the element id for the containing HTML element that is 
        /// rendered to the page for this component. This allows you to write id-based CSS rules to style 
        /// the specific instance of this component uniquely, and also to select sub-elements using this 
        /// component's id as the parent.
        /// Note: to avoid complications imposed by a unique id also see itemId and ref.
        /// Note: to access the container of an item see ownerCt.        
        /// </summary>
        public string Id { get; set; }

        /// <summary>
        /// An additional CSS class to apply to the div wrapping the form item element of this field. 
        /// If supplied, itemCls at the field level will override the default itemCls supplied at the 
        /// container level. The value specified for itemCls will be added to the default class ('x-form-item').
        /// Since it is applied to the item wrapper (see Ext.layout.FormLayout.fieldTpl), it allows you to 
        /// write standard CSS rules that can apply to the field, the label (if specified), or any other element 
        /// within the markup for the field.
        /// </summary>
        public string ItemCls { get; set; }

        /// <summary>
        /// An itemId can be used as an alternative way to get a reference to a component when no object 
        /// reference is available. Instead of using an id with Ext.getCmp, use itemId with 
        /// Ext.Container.getComponent which will retrieve itemId's or id's. Since itemId's are an index to
        /// the container's internal MixedCollection, the itemId is scoped locally to the container, 
        /// avoiding potential conflicts with Ext.ComponentMgr which requires a unique id.
        /// </summary>
        public string ItemId { get; set; }

        /// <summary>
        /// The separator to display after the text of each fieldLabel.
        /// </summary>
        public string LabelSeperator { get; set; }

        /// <summary>
        /// A CSS style specification string to apply directly to this field's label. 
        /// Defaults to the container's labelStyle value if set (e.g., Ext.layout.FormLayout.labelStyle , or '').
        /// </summary>
        public string LabelStyle { get; set; }

        /// <summary>
        /// An optional extra CSS class that will be added to this component's Element when the mouse 
        /// moves over the Element, and removed when the mouse moves out. (defaults to ''). 
        /// This can be useful for adding customized 'active' or 'hover' styles to the component or 
        /// any of its children using standard CSS rules.
        /// </summary>
        public string OverCls { get; set; }

        /// <summary>
        /// An object or array of objects that will provide custom functionality for this component. The only 
        /// requirement for a valid plugin is that it contain an init method that accepts a reference of type 
        /// Ext.Component. When a component is created, if any plugins are available, the component will call
        /// the init method on each plugin, passing a reference to itself. Each plugin can then call methods or 
        /// respond to events on the component as needed to provide its functionality.
        /// </summary>
        public object Plugins { get; set; }

        /// <summary>
        /// The registered ptype to create. This config option is not used when passing a config object into a 
        /// constructor. This config option is used only when lazy instantiation is being used, and a Plugin is 
        /// being specified not as a fully instantiated Component, but as a Component config object. The ptype 
        /// will be looked up at render time up to determine what type of Plugin to create.
        /// If you create your own Plugins, you may register them using Ext.ComponentMgr.registerPlugin in order 
        /// to be able to take advantage of lazy instantiation and rendering.
        /// </summary>
        public string PType { get; set; }

        /// <summary>
        /// A path specification, relative to the Component's ownerCt specifying into which ancestor Container 
        /// to place a named reference to this Component.
        /// The ancestor axis can be traversed by using '/' characters in the path
        /// </summary>
        public string Ref { get; set; }

        /// <summary>
        /// Specify the id of the element, a DOM element or an existing Element that this component will be 
        /// rendered into.
        /// </summary>
        public object RenderTo { get; set; }

        /// <summary>
        /// An array of events that, when fired, should trigger this component to save its state 
        /// (defaults to none). StateEvents may be any type of event supported by this component, 
        /// including browser or custom events (e.g., ['click', 'customerchange']).
        /// See stateful for an explanation of saving and restoring Component state.
        /// </summary>
        public object[] StateEvents { get; set; }

        /// <summary>
        /// A flag which causes the Component to attempt to restore the state of internal properties from a saved 
        /// state on startup. The component must have either a stateId or id assigned for state to be managed. 
        /// Auto-generated ids are not guaranteed to be stable across page loads and cannot be relied upon to 
        /// save and restore the same state for a component
        /// </summary>
        public bool Stateful { get; set; }

        /// <summary>
        /// A custom style specification to be applied to this component's Element. Should be a valid argument 
        /// to Ext.Element.applyStyles. 
        /// </summary>
        public string Style { get; set; }

        /// <summary>
        /// The registered xtype to create. This config option is not used when passing a config object into 
        /// a constructor. This config option is used only when lazy instantiation is being used, and a child 
        /// item of a Container is being specified not as a fully instantiated Component, but as a Component 
        /// config object. The xtype will be looked up at render time up to determine what type of child 
        /// Component to create.
        /// </summary>
        public string XType { get; set; }
    }
}
